package com.mew.user.events;

import com.mew.common.rest.events.GetOnlineGiftMessage;
import com.mew.user.service.OnlineGiftService;
import com.mew.common.rest.events.OnlineGiftMessage;
import com.mew.common.rest.user.UserMoneyResponseMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/onlinegift")
public class OnlineGiftController {

    @Autowired
    private OnlineGiftService onlineGiftService;



    @ResponseBody
    @GetMapping("/refresh")
    public OnlineGiftMessage refresh(@RequestParam("userId")long uid){
        OnlineGiftMessage message = onlineGiftService.refreshOnlineGift(uid);

        return message;
    }

    @ResponseBody
    @PostMapping("/get")
    public GetOnlineGiftMessage get(@RequestParam("type")int type, @RequestParam("uid")long uid){
        UserMoneyResponseMessage message = onlineGiftService.getGift(type, uid);
        GetOnlineGiftMessage getOnlineGiftMessage = new GetOnlineGiftMessage();
        getOnlineGiftMessage.setStatus(message.getStatus());
        getOnlineGiftMessage.setUserMoneyResponseMessage(message);
        getOnlineGiftMessage.setType(type);
        return getOnlineGiftMessage;
    }

}
